﻿using CommunityToolkit.Mvvm.Input;
using GetStartedApp.Models;
using System.Collections.ObjectModel;

namespace GetStartedApp.ViewModel.Page
{
    public partial class ItemsPanelPageViewModel : ViewModelBase
    {
        public ObservableCollection<ItemModel> Items { get; } = new ObservableCollection<ItemModel>();

        public ItemsPanelPageViewModel()
        {
            for (int i = 0; i < 50; i++)
            {
                this.Items.Add(new ItemModel("Item " + (i + 1)));
            }
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="item"></param>
        /// <remarks>
        /// 资料来自：https://www.coderbusy.com/archives/3165.html
        /// </remarks>
        [RelayCommand]
        private void Delete(ItemModel item)
        {
            this.Items.Remove(item);
        }
    }
}